/*
 * MerlinControlTest01View.java
 */
package Chronomotion;

import gnu.io.CommPortIdentifier;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

enum AXIS {

    PAN, TILT
}

enum DIRECTION {

    CW, CCW
}

public class MerlinControlTest01View extends FrameView implements Runnable {

    CommunicationManager MerlinController;
    private Thread Animator;

    public MerlinControlTest01View(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });

        MerlinController = new CommunicationManager();
        LoadComPorts();

        Animator = new Thread(this);
        Animator.start();
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ChronomotionApp.getApplication().getMainFrame();
            aboutBox = new MerlinControlTest01AboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ChronomotionApp.getApplication().show(aboutBox);
    }
    int last_pan_steps_per_second = 0;
    int last_tilt_steps_per_second = 0;
    long _last_time_stamp;
    private DefaultListModel ComPortListModel;

    public void SetPhaseState(String text) {
        Timeline_State.setText(text);
    }

    private void LoadComPorts() {
        ArrayList<CommPortIdentifier> h = MerlinController.getAvailableSerialPorts();
        ComPortListModel = new DefaultListModel();
        if (h.size() == 0) {
            ComPortListModel.addElement("No COM Port detected");
        } else {
            for (int i = 0; i < h.size(); i++) {
                ComPortListModel.addElement(h.get(i).getName());
            }
        }
        ComPortList.setModel(ComPortListModel);
    }

    public void Update() {
        long now = System.currentTimeMillis();
        long delta_time = now - _last_time_stamp;
        _last_time_stamp = now;

        MerlinController.ReadAxisPosition(AXIS.PAN);
        MerlinController.ReadAxisPosition(AXIS.TILT);

        pan_pos.setText(MerlinController.GetCurrentSteps(AXIS.PAN) - 8388608 + "");
        tilt_pos.setText(MerlinController.GetCurrentSteps(AXIS.TILT) - 8388608 + "");
        pan_totalsteps.setText(MerlinController.GetTotalSteps(AXIS.PAN) + "");
        tilt_totalsteps.setText(MerlinController.GetTotalSteps(AXIS.TILT) + "");
        pan_degrees.setText(((float) Math.round(((float) MerlinController.GetCurrentSteps(AXIS.PAN) - 8388608) / (float) MerlinController.GetTotalSteps(AXIS.PAN) * 360.0f * 10000.0f) / 10000.0f) + "");
        tilt_degrees.setText(((float) Math.round(((float) MerlinController.GetCurrentSteps(AXIS.TILT) - 8388608) / MerlinController.GetTotalSteps(AXIS.TILT) * 360.0f * 10000.0f) / 10000.0f) + "");

        int delta_pan_steps = (int) ((MerlinController.GetCurrentSteps(AXIS.PAN) - last_pan_steps_per_second) / (float) delta_time * 1000.0f);
        pan_steps_per_second.setText(delta_pan_steps + "");
        last_pan_steps_per_second = MerlinController.GetCurrentSteps(AXIS.PAN);
        pan_degrees_per_second.setText(Math.round((float) delta_pan_steps / (float) MerlinController.GetTotalSteps(AXIS.PAN) * 1000.0f) / 1000.0f * 360.0f * 60 + "");

        int delta_tilt_steps = (int) ((MerlinController.GetCurrentSteps(AXIS.TILT) - last_tilt_steps_per_second) / (float) delta_time * 1000.0f);
        tilt_steps_per_second.setText(delta_tilt_steps + "");
        last_tilt_steps_per_second = MerlinController.GetCurrentSteps(AXIS.TILT);
        tilt_degrees_per_second.setText(Math.round((float) delta_tilt_steps / (float) MerlinController.GetTotalSteps(AXIS.TILT) * 1000.0f) / 1000.0f * 360.0f * 60 + "");

        pan_sidereal.setText(MerlinController.GetSiderealRate(AXIS.PAN) + "");
        tilt_sidereal.setText(MerlinController.GetSiderealRate(AXIS.TILT) + "");

        if (timeline1 != null) {
            Timeline_Time.setText(timeline1.GetCurrentTime() + "");
            Timeline_Target.setText(timeline1.GetTargetTilt() + "");
        }
    }
    float _animator_fps = 10;

    public void run() {
        while (Thread.currentThread() == Animator) {
            Update();

            try {
                Thread.sleep((int) (1.0f / _animator_fps * 1000));
            } catch (InterruptedException e) {
                break;
            }
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        RIGHT = new javax.swing.JButton();
        UP = new javax.swing.JButton();
        LEFT = new javax.swing.JButton();
        DOWN = new javax.swing.JButton();
        mode_slow = new javax.swing.JRadioButton();
        mode_fast = new javax.swing.JRadioButton();
        speed_slider = new javax.swing.JSlider();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        pan_pos = new javax.swing.JLabel();
        tilt_pos = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        pan_totalsteps = new javax.swing.JLabel();
        tilt_totalsteps = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        pan_degrees = new javax.swing.JLabel();
        tilt_degrees = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        tilt_steps_per_second = new javax.swing.JLabel();
        pan_steps_per_second = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        pan_degrees_per_second = new javax.swing.JLabel();
        tilt_degrees_per_second = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        pan_sidereal = new javax.swing.JLabel();
        tilt_sidereal = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        pan_speed = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        pan_ratio = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        tilt_speed = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tilt_ratio = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        start = new javax.swing.JButton();
        stop = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        GOTO_pan = new javax.swing.JTextField();
        GOTO_tilt = new javax.swing.JTextField();
        goto_start_pan = new javax.swing.JButton();
        goto_stop_pan = new javax.swing.JButton();
        goto_start_tilt = new javax.swing.JButton();
        goto_stop_tilt = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        connect = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        ComPortList = new javax.swing.JList();
        jPanel10 = new javax.swing.JPanel();
        Timeline_Start = new javax.swing.JButton();
        jLabel17 = new javax.swing.JLabel();
        Timeline_Time = new javax.swing.JLabel();
        Timeline_Reset = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        jScrollPane3 = new javax.swing.JScrollPane();
        timeline1 = new Chronomotion.Timeline();
        SliderScaleY = new javax.swing.JSlider();
        SliderScaleX = new javax.swing.JSlider();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        timeline_edit_time = new javax.swing.JTextField();
        timeline_edit_value = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        Timeline_Target = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        Timeline_State = new javax.swing.JLabel();
        NewButton = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        shutter_delay = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        PostShutterDelay = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        buttonGroup1 = new javax.swing.ButtonGroup();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(Chronomotion.ChronomotionApp.class).getContext().getResourceMap(MerlinControlTest01View.class);
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        RIGHT.setText(resourceMap.getString("RIGHT.text")); // NOI18N
        RIGHT.setName("RIGHT"); // NOI18N
        RIGHT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                RIGHTMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                RIGHTMouseReleased(evt);
            }
        });
        jPanel2.add(RIGHT, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 70, -1, 50));

        UP.setText(resourceMap.getString("UP.text")); // NOI18N
        UP.setName("UP"); // NOI18N
        UP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                UPMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                UPMouseReleased(evt);
            }
        });
        jPanel2.add(UP, new org.netbeans.lib.awtextra.AbsoluteConstraints(55, 20, 60, 50));

        LEFT.setText(resourceMap.getString("LEFT.text")); // NOI18N
        LEFT.setName("LEFT"); // NOI18N
        LEFT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                LEFTMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                LEFTMouseReleased(evt);
            }
        });
        jPanel2.add(LEFT, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, 50));

        DOWN.setText(resourceMap.getString("DOWN.text")); // NOI18N
        DOWN.setName("DOWN"); // NOI18N
        DOWN.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                DOWNMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                DOWNMouseReleased(evt);
            }
        });
        jPanel2.add(DOWN, new org.netbeans.lib.awtextra.AbsoluteConstraints(55, 120, -1, 50));

        buttonGroup1.add(mode_slow);
        mode_slow.setText(resourceMap.getString("mode_slow.text")); // NOI18N
        mode_slow.setName("mode_slow"); // NOI18N
        jPanel2.add(mode_slow, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 190, -1, -1));

        buttonGroup1.add(mode_fast);
        mode_fast.setSelected(true);
        mode_fast.setText(resourceMap.getString("mode_fast.text")); // NOI18N
        mode_fast.setName("mode_fast"); // NOI18N
        jPanel2.add(mode_fast, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 190, -1, -1));

        speed_slider.setMajorTickSpacing(1);
        speed_slider.setMaximum(254);
        speed_slider.setMinimum(1);
        speed_slider.setMinorTickSpacing(1);
        speed_slider.setValue(240);
        speed_slider.setName("speed_slider"); // NOI18N
        jPanel2.add(speed_slider, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, 150, 20));

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N
        jPanel2.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N
        jPanel2.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, -1, -1));

        mainPanel.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 179, 280));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        pan_pos.setText(resourceMap.getString("pan_pos.text")); // NOI18N
        pan_pos.setName("pan_pos"); // NOI18N

        tilt_pos.setText(resourceMap.getString("tilt_pos.text")); // NOI18N
        tilt_pos.setName("tilt_pos"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        pan_totalsteps.setText(resourceMap.getString("pan_totalsteps.text")); // NOI18N
        pan_totalsteps.setName("pan_totalsteps"); // NOI18N

        tilt_totalsteps.setText(resourceMap.getString("tilt_totalsteps.text")); // NOI18N
        tilt_totalsteps.setName("tilt_totalsteps"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        pan_degrees.setText(resourceMap.getString("pan_degrees.text")); // NOI18N
        pan_degrees.setName("pan_degrees"); // NOI18N

        tilt_degrees.setText(resourceMap.getString("tilt_degrees.text")); // NOI18N
        tilt_degrees.setName("tilt_degrees"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(57, 57, 57))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addGap(61, 61, 61)))
                        .addGap(24, 24, 24)
                        .addComponent(pan_pos, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
                    .addComponent(jLabel6)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addGap(49, 49, 49)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pan_totalsteps, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                            .addComponent(tilt_totalsteps, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                            .addComponent(tilt_pos, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                            .addComponent(pan_degrees, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                            .addComponent(tilt_degrees, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(pan_pos))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tilt_pos)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(pan_totalsteps))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(tilt_totalsteps))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pan_degrees)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tilt_degrees)
                    .addComponent(jLabel7))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 10, -1, -1));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N

        tilt_steps_per_second.setText(resourceMap.getString("tilt_steps_per_second.text")); // NOI18N
        tilt_steps_per_second.setName("tilt_steps_per_second"); // NOI18N

        pan_steps_per_second.setText(resourceMap.getString("pan_steps_per_second.text")); // NOI18N
        pan_steps_per_second.setName("pan_steps_per_second"); // NOI18N

        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N

        jLabel22.setText(resourceMap.getString("jLabel22.text")); // NOI18N
        jLabel22.setName("jLabel22"); // NOI18N

        pan_degrees_per_second.setText(resourceMap.getString("pan_degrees_per_second.text")); // NOI18N
        pan_degrees_per_second.setName("pan_degrees_per_second"); // NOI18N

        tilt_degrees_per_second.setText(resourceMap.getString("tilt_degrees_per_second.text")); // NOI18N
        tilt_degrees_per_second.setName("tilt_degrees_per_second"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel20)
                    .addComponent(jLabel22)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tilt_degrees_per_second, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pan_degrees_per_second, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tilt_steps_per_second, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pan_steps_per_second, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(pan_steps_per_second))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(tilt_steps_per_second))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(pan_degrees_per_second))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(tilt_degrees_per_second))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 10, -1, -1));

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel6.border.title"))); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        pan_sidereal.setText(resourceMap.getString("pan_sidereal.text")); // NOI18N
        pan_sidereal.setName("pan_sidereal"); // NOI18N

        tilt_sidereal.setText(resourceMap.getString("tilt_sidereal.text")); // NOI18N
        tilt_sidereal.setName("tilt_sidereal"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tilt_sidereal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pan_sidereal, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(37, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(pan_sidereal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(tilt_sidereal))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 290, -1, 70));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel7.border.title"))); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        pan_speed.setText(resourceMap.getString("pan_speed.text")); // NOI18N
        pan_speed.setName("pan_speed"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        pan_ratio.setText(resourceMap.getString("pan_ratio.text")); // NOI18N
        pan_ratio.setName("pan_ratio"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                        .addComponent(pan_speed, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                        .addComponent(pan_ratio, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(pan_speed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(pan_ratio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        tilt_speed.setText(resourceMap.getString("tilt_speed.text")); // NOI18N
        tilt_speed.setName("tilt_speed"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        tilt_ratio.setText(resourceMap.getString("tilt_ratio.text")); // NOI18N
        tilt_ratio.setName("tilt_ratio"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                        .addComponent(tilt_speed, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                        .addComponent(tilt_ratio, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tilt_speed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(tilt_ratio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        start.setText(resourceMap.getString("start.text")); // NOI18N
        start.setName("start"); // NOI18N
        start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startActionPerformed(evt);
            }
        });

        stop.setText(resourceMap.getString("stop.text")); // NOI18N
        stop.setEnabled(false);
        stop.setName("stop"); // NOI18N
        stop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(start)
                    .addComponent(stop)))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(start)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(stop))
            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        mainPanel.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 170, -1, -1));

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel8.border.title"))); // NOI18N
        jPanel8.setName("jPanel8"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        GOTO_pan.setText(resourceMap.getString("GOTO_pan.text")); // NOI18N
        GOTO_pan.setName("GOTO_pan"); // NOI18N

        GOTO_tilt.setText(resourceMap.getString("GOTO_tilt.text")); // NOI18N
        GOTO_tilt.setName("GOTO_tilt"); // NOI18N

        goto_start_pan.setText(resourceMap.getString("goto_start_pan.text")); // NOI18N
        goto_start_pan.setName("goto_start_pan"); // NOI18N
        goto_start_pan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goto_start_panActionPerformed(evt);
            }
        });

        goto_stop_pan.setText(resourceMap.getString("goto_stop_pan.text")); // NOI18N
        goto_stop_pan.setName("goto_stop_pan"); // NOI18N
        goto_stop_pan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goto_stop_panActionPerformed(evt);
            }
        });

        goto_start_tilt.setText(resourceMap.getString("goto_start_tilt.text")); // NOI18N
        goto_start_tilt.setName("goto_start_tilt"); // NOI18N
        goto_start_tilt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goto_start_tiltActionPerformed(evt);
            }
        });

        goto_stop_tilt.setText(resourceMap.getString("goto_stop_tilt.text")); // NOI18N
        goto_stop_tilt.setName("goto_stop_tilt"); // NOI18N
        goto_stop_tilt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                goto_stop_tiltActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(GOTO_tilt, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GOTO_pan, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(goto_start_pan)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(goto_stop_pan))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(goto_start_tilt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(goto_stop_tilt)))
                .addGap(255, 255, 255))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(GOTO_pan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(GOTO_tilt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(goto_start_pan)
                            .addComponent(goto_stop_pan))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(goto_start_tilt)
                            .addComponent(goto_stop_tilt))))
                .addContainerGap())
        );

        mainPanel.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 290, 345, 85));

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel9.border.title"))); // NOI18N
        jPanel9.setName("jPanel9"); // NOI18N

        connect.setText(resourceMap.getString("connect.text")); // NOI18N
        connect.setName("connect"); // NOI18N
        connect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connectActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        ComPortList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        ComPortList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        ComPortList.setName("ComPortList"); // NOI18N
        jScrollPane1.setViewportView(ComPortList);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(connect)
                .addGap(12, 12, 12))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(connect))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 380, 190, -1));

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel10.border.title"))); // NOI18N
        jPanel10.setName("jPanel10"); // NOI18N

        Timeline_Start.setText(resourceMap.getString("Timeline_Start.text")); // NOI18N
        Timeline_Start.setName("Timeline_Start"); // NOI18N
        Timeline_Start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Timeline_StartActionPerformed(evt);
            }
        });

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        Timeline_Time.setText(resourceMap.getString("Timeline_Time.text")); // NOI18N
        Timeline_Time.setName("Timeline_Time"); // NOI18N

        Timeline_Reset.setText(resourceMap.getString("Timeline_Reset.text")); // NOI18N
        Timeline_Reset.setEnabled(false);
        Timeline_Reset.setName("Timeline_Reset"); // NOI18N
        Timeline_Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Timeline_ResetActionPerformed(evt);
            }
        });

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Remotehead");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Pitch");
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Yaw");
        treeNode1.add(treeNode2);
        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTree1.setCellRenderer(null);
        jTree1.setName("jTree1"); // NOI18N
        jScrollPane2.setViewportView(jTree1);

        jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane3.setViewportBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jScrollPane3.viewportBorder.lineColor"))); // NOI18N
        jScrollPane3.setName("jScrollPane3"); // NOI18N

        timeline1.setName("timeline1"); // NOI18N
        timeline1.SetParent(this);

        javax.swing.GroupLayout timeline1Layout = new javax.swing.GroupLayout(timeline1);
        timeline1.setLayout(timeline1Layout);
        timeline1Layout.setHorizontalGroup(
            timeline1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 442, Short.MAX_VALUE)
        );
        timeline1Layout.setVerticalGroup(
            timeline1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 181, Short.MAX_VALUE)
        );

        jScrollPane3.setViewportView(timeline1);

        SliderScaleY.setOrientation(javax.swing.JSlider.VERTICAL);
        SliderScaleY.setPaintTicks(true);
        SliderScaleY.setName("SliderScaleY"); // NOI18N
        SliderScaleY.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                SliderScaleYMouseDragged(evt);
            }
        });
        SliderScaleY.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                SliderScaleYPropertyChange(evt);
            }
        });
        SliderScaleY.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SliderScaleYKeyReleased(evt);
            }
        });

        SliderScaleX.setPaintTicks(true);
        SliderScaleX.setName("SliderScaleX"); // NOI18N
        SliderScaleX.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                SliderScaleXMouseDragged(evt);
            }
        });
        SliderScaleX.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                SliderScaleXPropertyChange(evt);
            }
        });
        SliderScaleX.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SliderScaleXKeyReleased(evt);
            }
        });

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        timeline_edit_time.setText(resourceMap.getString("timeline_edit_time.text")); // NOI18N
        timeline_edit_time.setName("timeline_edit_time"); // NOI18N
        timeline_edit_time.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                timeline_edit_timeActionPerformed(evt);
            }
        });

        timeline_edit_value.setText(resourceMap.getString("timeline_edit_value.text")); // NOI18N
        timeline_edit_value.setName("timeline_edit_value"); // NOI18N
        timeline_edit_value.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                timeline_edit_valueActionPerformed(evt);
            }
        });

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        Timeline_Target.setText(resourceMap.getString("Timeline_Target.text")); // NOI18N
        Timeline_Target.setName("Timeline_Target"); // NOI18N

        jLabel26.setText(resourceMap.getString("jLabel26.text")); // NOI18N
        jLabel26.setName("jLabel26"); // NOI18N

        Timeline_State.setText(resourceMap.getString("Timeline_State.text")); // NOI18N
        Timeline_State.setName("Timeline_State"); // NOI18N

        NewButton.setText(resourceMap.getString("NewButton.text")); // NOI18N
        NewButton.setName("NewButton"); // NOI18N
        NewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(4, 4, 4)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(Timeline_Time, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(Timeline_Target, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(Timeline_Start)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Timeline_Reset)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton1))
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(4, 4, 4)
                                .addComponent(Timeline_State, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(timeline_edit_time, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(timeline_edit_value, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23)))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(SliderScaleX, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE))))
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(SliderScaleY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(NewButton)))
                .addGap(117, 117, 117))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(Timeline_Time))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(Timeline_Target)))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel23)
                            .addComponent(jLabel18)
                            .addComponent(jLabel26)
                            .addComponent(Timeline_State))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(Timeline_Reset)
                            .addComponent(Timeline_Start)
                            .addComponent(jButton1)
                            .addComponent(jButton2)
                            .addComponent(timeline_edit_time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(timeline_edit_value, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(NewButton))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(SliderScaleY, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(SliderScaleX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(69, 69, 69))
        );

        mainPanel.add(jPanel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 380, 650, 330));
        jPanel10.getAccessibleContext().setAccessibleName(resourceMap.getString("jPanel10.AccessibleContext.accessibleName")); // NOI18N

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel11.border.title"))); // NOI18N
        jPanel11.setName("jPanel11"); // NOI18N

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N

        shutter_delay.setText(resourceMap.getString("shutter_delay.text")); // NOI18N
        shutter_delay.setName("shutter_delay"); // NOI18N
        shutter_delay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                shutter_delayActionPerformed(evt);
            }
        });
        shutter_delay.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                shutter_delayPropertyChange(evt);
            }
        });

        jLabel27.setText(resourceMap.getString("jLabel27.text")); // NOI18N
        jLabel27.setName("jLabel27"); // NOI18N

        PostShutterDelay.setText(resourceMap.getString("PostShutterDelay.text")); // NOI18N
        PostShutterDelay.setName("PostShutterDelay"); // NOI18N
        PostShutterDelay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PostShutterDelayActionPerformed(evt);
            }
        });
        PostShutterDelay.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                PostShutterDelayPropertyChange(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                        .addComponent(shutter_delay, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                        .addComponent(PostShutterDelay, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(shutter_delay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addGap(32, 32, 32)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(PostShutterDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        mainPanel.add(jPanel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 260, -1, -1));

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        mainPanel.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 130, -1, -1));

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(Chronomotion.ChronomotionApp.class).getContext().getActionMap(MerlinControlTest01View.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 865, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 695, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void RIGHTMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RIGHTMouseReleased
        MerlinController.StopMotor(AXIS.PAN);
    }//GEN-LAST:event_RIGHTMouseReleased

    private void RIGHTMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RIGHTMousePressed
        int ratio = 1;
        if (mode_slow.isSelected()) {
            ratio = 1;
        }
        if (mode_fast.isSelected()) {
            ratio = 3;
        }

        MerlinController.RotateAxis(AXIS.PAN, 256 - speed_slider.getValue(), ratio, DIRECTION.CW);
    }//GEN-LAST:event_RIGHTMousePressed

    private void UPMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UPMousePressed
        int ratio = 1;
        if (mode_slow.isSelected()) {
            ratio = 1;
        }
        if (mode_fast.isSelected()) {
            ratio = 3;
        }

        MerlinController.RotateAxis(AXIS.TILT, 256 - speed_slider.getValue(), ratio, DIRECTION.CW);
    }//GEN-LAST:event_UPMousePressed

    private void UPMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UPMouseReleased
        MerlinController.StopMotor(AXIS.TILT);
    }//GEN-LAST:event_UPMouseReleased

    private void DOWNMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DOWNMousePressed
        int ratio = 1;
        if (mode_slow.isSelected()) {
            ratio = 1;
        }
        if (mode_fast.isSelected()) {
            ratio = 3;
        }

        MerlinController.RotateAxis(AXIS.TILT, 256 - speed_slider.getValue(), ratio, DIRECTION.CCW);
    }//GEN-LAST:event_DOWNMousePressed

    private void DOWNMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DOWNMouseReleased
        MerlinController.StopMotor(AXIS.TILT);
    }//GEN-LAST:event_DOWNMouseReleased

    private void LEFTMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LEFTMousePressed
        int ratio = 1;
        if (mode_slow.isSelected()) {
            ratio = 1;
        }
        if (mode_fast.isSelected()) {
            ratio = 3;
        }

        MerlinController.RotateAxis(AXIS.PAN, 256 - speed_slider.getValue(), ratio, DIRECTION.CCW);
    }//GEN-LAST:event_LEFTMousePressed

    private void LEFTMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LEFTMouseReleased
        MerlinController.StopMotor(AXIS.PAN);
    }//GEN-LAST:event_LEFTMouseReleased

    private void startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startActionPerformed
        MerlinController.RotateAxis(AXIS.PAN, pan_speed.getText(), Integer.parseInt(pan_ratio.getText()), DIRECTION.CCW);
        MerlinController.RotateAxis(AXIS.TILT, tilt_speed.getText(), Integer.parseInt(tilt_ratio.getText()), DIRECTION.CCW);

        stop.setEnabled(true);
        start.setEnabled(false);
    }//GEN-LAST:event_startActionPerformed

    private void stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopActionPerformed
        MerlinController.StopMotor(AXIS.PAN);
        MerlinController.StopMotor(AXIS.TILT);

        stop.setEnabled(false);
        start.setEnabled(true);
    }//GEN-LAST:event_stopActionPerformed

    private void goto_start_panActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goto_start_panActionPerformed
        MerlinController.GotoPosition(AXIS.PAN, Float.parseFloat(GOTO_pan.getText()));
    }//GEN-LAST:event_goto_start_panActionPerformed

    private void goto_stop_panActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goto_stop_panActionPerformed
        MerlinController.StopMotor(AXIS.PAN);
    }//GEN-LAST:event_goto_stop_panActionPerformed

    private void goto_start_tiltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goto_start_tiltActionPerformed
        MerlinController.GotoPosition(AXIS.TILT, Float.parseFloat(GOTO_tilt.getText()));
    }//GEN-LAST:event_goto_start_tiltActionPerformed

    private void goto_stop_tiltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goto_stop_tiltActionPerformed
        MerlinController.StopMotor(AXIS.TILT);
    }//GEN-LAST:event_goto_stop_tiltActionPerformed

    private void connectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectActionPerformed
        MerlinController.Init(ComPortList.getSelectedValue().toString());
    }//GEN-LAST:event_connectActionPerformed

    private void Timeline_StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Timeline_StartActionPerformed
        timeline1.ChangeState(STATE.RUNNING);
        Timeline_Reset.setEnabled(true);
        Timeline_Start.setEnabled(false);
    }//GEN-LAST:event_Timeline_StartActionPerformed

    private void Timeline_ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Timeline_ResetActionPerformed
        timeline1.ChangeState(STATE.STOPPED);
        Timeline_Reset.setEnabled(false);
        Timeline_Start.setEnabled(true);
    }//GEN-LAST:event_Timeline_ResetActionPerformed

    private void SliderScaleXPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_SliderScaleXPropertyChange
        timeline1.setScaleX(SliderScaleX.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleXPropertyChange

    private void SliderScaleYPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_SliderScaleYPropertyChange
        timeline1.setScaleY(SliderScaleY.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleYPropertyChange

    private void SliderScaleXMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SliderScaleXMouseDragged
        timeline1.setScaleX(SliderScaleX.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleXMouseDragged

    private void SliderScaleYMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SliderScaleYMouseDragged
        timeline1.setScaleY(SliderScaleY.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleYMouseDragged

    private void SliderScaleYKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SliderScaleYKeyReleased
        timeline1.setScaleY(SliderScaleY.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleYKeyReleased

    private void SliderScaleXKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SliderScaleXKeyReleased
        timeline1.setScaleX(SliderScaleX.getValue());
        timeline1.Redraw();
    }//GEN-LAST:event_SliderScaleXKeyReleased
    private int highlightindex = 0;
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        highlightindex++;
        if (highlightindex < 0) {
            highlightindex = 0;
        }
        if (highlightindex > timeline1.GetNumberOfKeyframes() - 1) {
            highlightindex = timeline1.GetNumberOfKeyframes() - 1;
        }
        timeline1.SetKeyframeHighlight(highlightindex);

        timeline_edit_value.setText(timeline1.GetParameter(highlightindex, "pitch") + "");
        timeline_edit_time.setText(timeline1.GetTime(highlightindex) + "");
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        --highlightindex;
        if (highlightindex < 0) {
            highlightindex = 0;
        }
        if (highlightindex > timeline1.GetNumberOfKeyframes() - 1) {
            highlightindex = timeline1.GetNumberOfKeyframes() - 1;
        }
        timeline1.SetKeyframeHighlight(highlightindex);

        timeline_edit_value.setText(timeline1.GetParameter(highlightindex, "pitch") + "");
        timeline_edit_time.setText(timeline1.GetTime(highlightindex) + "");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void timeline_edit_valueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeline_edit_valueActionPerformed
        timeline1.SetParameter(highlightindex, "pitch", Integer.parseInt(timeline_edit_value.getText()));
        timeline1.Redraw();
    }//GEN-LAST:event_timeline_edit_valueActionPerformed

    private void timeline_edit_timeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeline_edit_timeActionPerformed
        timeline1.SetTime(highlightindex, Integer.parseInt(timeline_edit_time.getText()));
        timeline1.Redraw();
    }//GEN-LAST:event_timeline_edit_timeActionPerformed

    private void shutter_delayPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_shutter_delayPropertyChange
        if (!shutter_delay.getText().equals("")) {
            timeline1.setTimelapseShutterPeriod(Float.parseFloat(shutter_delay.getText()));
            timeline1.Redraw();
        }
    }//GEN-LAST:event_shutter_delayPropertyChange

    private void shutter_delayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shutter_delayActionPerformed
        if (!shutter_delay.getText().equals("")) {
            timeline1.setTimelapseShutterPeriod(Float.parseFloat(shutter_delay.getText()));
            timeline1.Redraw();
        }
    }//GEN-LAST:event_shutter_delayActionPerformed

    private void PostShutterDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PostShutterDelayActionPerformed
        if (!PostShutterDelay.getText().equals("")) {
            timeline1.setPostShootDelay(Float.parseFloat(PostShutterDelay.getText()));
            timeline1.Redraw();
        }
    }//GEN-LAST:event_PostShutterDelayActionPerformed

    private void PostShutterDelayPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_PostShutterDelayPropertyChange
        if (!PostShutterDelay.getText().equals("")) {
            timeline1.setPostShootDelay(Float.parseFloat(PostShutterDelay.getText()));
            timeline1.Redraw();
        }
    }//GEN-LAST:event_PostShutterDelayPropertyChange

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        this.MerlinController.TriggerShutter();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void NewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewButtonActionPerformed
         this.timeline1.OrderKeyframes();
    }//GEN-LAST:event_NewButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList ComPortList;
    private javax.swing.JButton DOWN;
    private javax.swing.JTextField GOTO_pan;
    private javax.swing.JTextField GOTO_tilt;
    private javax.swing.JButton LEFT;
    private javax.swing.JButton NewButton;
    private javax.swing.JTextField PostShutterDelay;
    private javax.swing.JButton RIGHT;
    private javax.swing.JSlider SliderScaleX;
    private javax.swing.JSlider SliderScaleY;
    private javax.swing.JButton Timeline_Reset;
    private javax.swing.JButton Timeline_Start;
    private javax.swing.JLabel Timeline_State;
    private javax.swing.JLabel Timeline_Target;
    private javax.swing.JLabel Timeline_Time;
    private javax.swing.JButton UP;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton connect;
    private javax.swing.JButton goto_start_pan;
    private javax.swing.JButton goto_start_tilt;
    private javax.swing.JButton goto_stop_pan;
    private javax.swing.JButton goto_stop_tilt;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTree jTree1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JRadioButton mode_fast;
    private javax.swing.JRadioButton mode_slow;
    private javax.swing.JLabel pan_degrees;
    private javax.swing.JLabel pan_degrees_per_second;
    private javax.swing.JLabel pan_pos;
    private javax.swing.JTextField pan_ratio;
    private javax.swing.JLabel pan_sidereal;
    private javax.swing.JTextField pan_speed;
    private javax.swing.JLabel pan_steps_per_second;
    private javax.swing.JLabel pan_totalsteps;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JTextField shutter_delay;
    private javax.swing.JSlider speed_slider;
    private javax.swing.JButton start;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JButton stop;
    private javax.swing.JLabel tilt_degrees;
    private javax.swing.JLabel tilt_degrees_per_second;
    private javax.swing.JLabel tilt_pos;
    private javax.swing.JTextField tilt_ratio;
    private javax.swing.JLabel tilt_sidereal;
    private javax.swing.JTextField tilt_speed;
    private javax.swing.JLabel tilt_steps_per_second;
    private javax.swing.JLabel tilt_totalsteps;
    private Chronomotion.Timeline timeline1;
    private javax.swing.JTextField timeline_edit_time;
    private javax.swing.JTextField timeline_edit_value;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
